<?php 
    $auth = Zend_Auth::getInstance();
    if ($auth->hasIdentity()) {
        $role = $auth->getIdentity()->role;
    }
    else{
        $role = null;
    }
    echo '<h3 class="adminTitle">分类列表</h3>';
    echo '<div class="adminContent">';
    if ($this->categories){
        foreach ($this->categories as $category){
            echo "<dl class = 'listCatetory'>";
            $num = substr_count($category->path,',');
            if ($num > 0){
                echo "<dt>";
                for ($i=1; $i<=$num; $i++){
                    echo "&nbsp;&nbsp;&nbsp;&nbsp;";
                }
                echo "&#166;--".$category->name."</dt>";

            }
            else{
                echo "<dt>".$category->name."</dt>";
            }
            if ($role == 'admin'){
                echo "<dd><a href = '/admin/category/delete/id/".$category->id."'>删除</a></dd>";
                echo "<dd><a href = '/admin/category/update/id/".$category->id."'>更新</a></dd>";
            }
            echo "</dl>";
        }
        echo '<a href = "/admin/category/create">添加分类</a>';
        echo '</div>';
    }
?>